/**********************************************************************************
 * Copyright (c) 2012 - 2012,  quick_tools, All right reserved
 * Title: com.adc.quicktools.file  WildcardsFilter.java 
 * @author shen  shenqiao2012@163.com 
 *  2012-7-20 下午12:01:30 
 *********************************************************************************/


package com.adc.quicktools.file;

import java.io.File;
import java.io.FilenameFilter;

import com.adc.quicktools.StringUtil;




public class WildcardsFilter implements FilenameFilter {

	/** 
	 *     
	 */
	public WildcardsFilter() {
		// TODO Auto-generated constructor stub
	}
	
	public WildcardsFilter(String matchString){
		this.matchString=WildcardUtil.wildcardsToRegex(matchString);
	}

	private String matchString=null;
	/**
	 * Description:  
	 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) 
	 */
	@Override
	public boolean accept(File dir, String fileName) {
		if (StringUtil.checkStringValue(matchString)) {
			return fileName.matches(matchString);
		}else {
			return true;
		}
		
	}
	public String getMatchString() {
		return matchString;
	}
	public void setMatchString(String matchString) {
		this.matchString = matchString;
	}
	
	
}
